﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Shop.Application.Products;
using Shop.Application.Products.Dto;
using Shop.DB;

namespace Shop.UI.API
{
    [Route("API/[controller]")]
    public class ProductController : Controller
    {
        private DBContext _context;

        public ProductController(DBContext context)
        {
            _context = context;
        }

        [HttpPost("CreateProduct")]
        public IActionResult CreateProduct(ProductInput input) => Ok(new CreateProduct(_context).Do(input));

        [HttpGet("GetProductByID")]
        public IActionResult GetProductByID(Guid id) => Ok(new GetProductByProductID(_context).Do(id));

        [HttpGet("GetProductByName")]
        public IActionResult GetProductByName(string name) => Ok(new GetProductByName(_context).Do(name));

        [HttpDelete("DeleteProduct")]
        public IActionResult DeleteProduct(Guid id) => Ok(new DeleteProduct(_context).Do(id));
    }
    }
